import json

from api.BaseService import BaseService


class OrderSettingService(BaseService):
    """
    预约服务
    """

    def __init__(self):
        super().__init__()
        self.service_name = "OrderSettingService"

    def getOrderSettingByMonth(self, data):
        """
        :param data:查找某月的预约信息
        :return:返回当月的预约信息
        """
        resp = self.dubbo_client.invoke(self.service_name, "getOrderSettingByMonth", data)
        return json.loads(resp)

    def editNumberByDate(self, data):
        """
        :param data:修改的预约时间及相关信息
        :return:成功返回None,否则返回Failed
        """
        resp = self.dubbo_client.invoke(self.service_name, "editNumberByDate", data)
        return json.loads(resp)

    def add(self, data):
        """
        :param data:需要添加预约信息的时间及其相关信息
        :return:成功返回None,否则返回Failed
        """
        resp = self.dubbo_client.invoke(self.service_name, "add", data)
        return json.loads(resp)


if __name__ == '__main__':
    oss = OrderSettingService()
    data = "2024-05"
    print(oss.getOrderSettingByMonth(data))
    info = {"orderDate": "2024-05-26 00:00:00", "number": 220, "class": "com.itheima.pojo.OrderSetting"}
    print(oss.editNumberByDate(info))
    data = [{"orderDate": "2024-05-01 00:00:00", "number": 300}]
    print(oss.add(data))
